﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Htse.Blue.Models;
using Htse.Blue.Logic.Validation;
using Htse.Blue.Data;

namespace Htse.Blue.Logic
{
	public class CityService :
		ServiceBase<City, int, ICityRepository>,
		ICityService
	{
		public CityService(IValidationDictionary<City> validationDictionary)
			: base(validationDictionary, new CityRepository())
		{

		}

		public CityService(
			IValidationDictionary<City> validationDictionary,
			ICityRepository cityRepository)
			: base(validationDictionary, cityRepository)
		{
		}

		#region ICityService Members

		public IEnumerable<string> GetCitiesNames()
		{
			return repository
				.GetAll()
				.OrderBy(c => c.Name)
				.Select(c=>c.Name)
				.AsEnumerable();
		}

		public City GetByName(string name)
		{
			return repository.GetByName(name);
		}

		#endregion
	}
}
